home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 21
/
CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso
/
CUCD
/
Programming
/
RTGMaster
/
devdocs
/
Skeleton.asm
< prev
next >
Wrap
Assembly Source File
|
1997-09-26
|
11KB
|
414 lines
; This is a code skeleton for a sublibrary for the
; rtgmaster.library ... no guarantie that it is bugfree :)
; I extracted it out of an existing library source of
; mine ... Sometimes you will have toi exchange CGX
; by the name of YOUR sublibrary in this code !!!
; Also, this code may be incomplete...
; Code provided by you HAS to be 100% in Assembly language.
; You will have to write all needed include files, too...
; (look at the include files of the other sublibs for
; examples and for learning what structures exist...
; study the autodocs, too...)
; so the files that have to be done by you to do a sublibrary
; for the XYZ-GFX Board would be (note, that the short name
; for the Board has to be three letters + blank or four letters) :
; rtgXYZ.i
; rtgXYZ.h
; rtgXYZ.library.asm
; rtgXYZ.library
LibVersion EQU 2
LibRevision EQU 0
; Look at rtgmaster.guide to get explained which version number has to
; feature which functions
LibName MACRO
Dc.b "rtgXYZ"
; INSERT LIBNAME HERE !!!
; LIBNAME HAS TO BE rtg and UP TO
; FOUR LETTERS !!! (or three letters + Blank)
ENDM
LibVersion MACRO
Dc.b "2"
Dc.b ".","0"
ENDM
; Look at rtgmaster.guide to get the version numbers explained...
XYZ_ID EQU "XYZ "
; PUT HERE THE NAME OF THE LIB WITHPOUT rtg
; AND FILL IN BLANKS, IF NEEDED...
incdir "INCLUDE:"
include "exec/initializers.i"
include "exec/libraries.i"
include "exec/types.i"
include "exec/funcdef.i"
include "exec/memory.i"
include "utility/tagitem.i"
include "rtgmaster/rtgsublibs.i"
include "rtgmaster/rtgmaster.i"
include "rtgmaster/rtgXYZ.i"
include "cybergraphics/cybergraphics.i"
include "intuition/screens.i"
include "include:utility/utility_lib.i"
; INCLUDES AND DEFINES HERE...
_LVOAllocMem EQU -198
_LVOFreeMem EQU -210
LibraryExecuteCode Moveq #0,d0
Rts
CNOP 0,4
rt_MatchTag Dc.w $4afc
rt_ROMTag Dc.l rt_MatchTag
rt_EndSkip Dc.l lib_EndCode
rt_Flags Dc.b 128 ; RTG_AUTOINIT
rt_Version Dc.b LibVersion
rt_Type Dc.b NT_LIBRARY
rt_Pri Dc.b 0
rt_Name Dc.l Text_Library
rt_IDString Dc.l Text_Library_ID
rt_Init Dc.l InitTable
Text_Library LibName
Dc.b ".library",0
Text_Library_ID LibName
Dc.b " "
LibVersion
Dc.b " (16.2.95)",10,0
Dc.b "Created by Steffen Häuser",10,0
; Put here your copyright...
CNOP 0,4
InitTable Dc.l rbXYZ_SIZEOF
; HERE rbXYZ_SIZEOF with appropriate name has to be
; put in...
Dc.l FunctionTable
Dc.l DataTable ;something like primary init
Dc.l InitRtgLibrary
FunctionTable ;OS functions
Dc.l lib.Open
Dc.l lib.Close
Dc.l lib.ExpungeLib
Dc.l lib.ExtFunc
;public functions
; *************************************************
; ** Don't change the order of these function !! **
; *************************************************
;
Dc.l _OpenRtgScreen
Dc.l _CloseRtgScreen
Dc.l _GetRtgScreenData
Dc.l _GetScreenModes
Dc.l _FreeScreenModes
Dc.l _LockRtgScreen
Dc.l _UnlockRtgScreen
Dc.l _GetBufAdr
Dc.l _GetSegment
Dc.l _SetSegment
Dc.l _LoadRGBRtg
Dc.l _RtgScreenAtFront
Dc.l _SwitchScreens
Dc.l _WriteRtgPixel
Dc.l _WriteRtgPixelRGB
Dc.l _FillRtgRect
Dc.l _FillRtgRectRGB
Dc.l _WriteRtgPixelArray
Dc.l _WriteRtgPixelRGBArray
dc.l _CopyRtgPixelArray
dc.l _CopyRtgBlit
dc.l _DrawRtgLine
dc.l _DrawRtgLineRGB
dc.l _WaitRtgSwitch
dc.l _WaitRtgBlit
dc.l _RtgWaitTOF
dc.l _RtgBlit
dc.l _RtgBltClear
dc.l _CallRtgC2P
dc.l _RtgText
dc.l _RtgSetFont
dc.l _RtgClearPointer
dc.l _RtgSetPointer
dc.l _RtgSetTextMode
dc.l _RtgOpenFont
dc.l _RtgCloseFont
dc.l _RtgSetTextModeRGB
dc.l _RtgInitRDCMP
dc.l _RtgWaitRDCMP
dc.l _RtgGetMsg
dc.l _RtgReplyMsg
dc.l _RtgCheckVSync
Dc.l -1
DataTable INITBYTE LN_TYPE,NT_LIBRARY
INITLONG LN_NAME,Text_Library
INITBYTE LIB_FLAGS,LIBF_CHANGED|LIBF_SUMUSED
;something has changed the library since last sum;
;indicates if the library allows checksumming
INITWORD LIB_VERSION,LibVersion
INITWORD LIB_REVISION,LibRevision
INITLONG LIB_IDSTRING,Text_Library_ID
dc.l 0
lib.Open ; IN: d0 = version
; IN: a6 = *library base
;OUT: d0 = *library base, if successful, 0 otherwise
Addq.w #1,LIB_OPENCNT(a6)
Bclr #LIBB_DELEXP,LIB_FLAGS(a6)
Move.l a6,d0
Rts
lib.Close ; IN: a6 = *library base
;OUT: d0 = *SegList, if no longer open and delayed expunge,
; 0 otherwise
Moveq #0,d0
Subq.w #1,LIB_OPENCNT(a6)
Bne.s .OpenCountNot0
Btst #LIBB_DELEXP,LIB_FLAGS(a6)
Beq.s .DontExpungeLibrary
Bsr.s lib.ExpungeLib
.OpenCountNot0
.DontExpungeLibrary Rts
lib.ExpungeLib
;according to Autodocs/RemLibrary a Forbid/Permit pair MUST be placed around
;RemLibrary to be secure. This should be granted, for ROM code calls this
;typically. If not called from ROM, there MUST be Forbid/Permit.
; IN: a6 = *library base
;OUT: d0 = *SegList, if no longer open and delayed expunge,
; 0 otherwise
Tst.w LIB_OPENCNT(a6)
Bne.s .OpenCountNot0
;free all resources (fi close libraries) here that were opened in
;Init_xpkHUFFLibrary
;xpkHUFF_EL_RemoveLibraryNode:
Movem.l d1-d7/a0-a6,-(sp)
Move.l a6,a5
Bsr SmartFree
Move.l a6,a5
Move.l a6,a1
Move.l 4.w,a6
Jsr -252(a6)
Move.l rbXYZ_SegList(a5),d7
; THE SEGLIST !!!
Move.l a5,a1 *xpkHUFF library base
Moveq #0,d0
Move.w LIB_NEGSIZE(a5),d0
Sub.l d0,a1 equ *memory to free
Add.w LIB_POSSIZE(a5),d0 equ size of memory to free
Move.l 4.w,a6
Jsr -198(a6)
Move.l d7,d0 return SegList
Movem.l (sp)+,d1-d7/a0-a6
Rts
.OpenCountNot0 Bset #LIBB_DELEXP,LIB_FLAGS(a6) ;next CloseLib will expunge
;the library if OpenCount = 0
Moveq #0,d0
Rts
lib.ExtFunc Moveq #0,d0
Rts
InitRtgLibrary
; IN: d0 = *library base
; IN: a0 = *segment list
; IN: a6 = *execbase
;OUT: d0 = *librarybase, if succesfull, 0 otherwise
Movem.l a0-a1/d0-d1/d6/a5,-(sp)
Move.l d0,a5
Move.l a0,rbXYZ_SegList(a5)
Move.l a6,rbXYZ_ExecBase(a5)
; Insert XYZ...
; PUT LIBRARY INIT CODE HERE... especially
; open all needed libraries...
Move.l a5,d0
Bra.s .Ok
; You should only jump to .Ok if the graphics
; board intended for the use of this sublibrary
; was FOUND (you have to provide some code for
; this), if this is possible for the Board...
; Do not only check for the libraries being
; installed, check for Screenmodes or Board
; Drivers... (if possible...) If no board was
found, jump to .Error
.Ok Movem.l (sp)+,a0-a1/d0-d1/d6/a5
Rts
.Error movem.l (sp)+,a0-a1/d0-d1/d6/a5
move.l #0,d0
rts
SmartFree
; Close the Libraries again here...
; if they are not already close... will
; be used in errorcase, too...
; And now include all the functions HERE... you should
; at LEAST support all V1.0 functions... you do not need
; to support 2.0 functions up to now, if you have not
; the time to implement all this stuff... As far as i got
; it from John Hendrikx, rtgmaster.library does not support
; all rtg 2.0 functions anyways, up to now ...
_GetScreenmodes
; IN: a6.l = rtgXYZ.library base
;OUT: d0.l = List of ScreenModes or zero
;COM: you may destroy d0-d1,a0-a1
; This function will be called by rtgmaster.library
; and will return a list of Screenmodes available on
; this Board. Be sure it returns 0, if the Board is not
; available, and that it does not return Screenmodes
; that do not belong to the Board... You will have
; to save the Screenmodes in the RTGScreenmode format
; that is described in the Includes... you will also
; have to write a rtgXXX.h and a rtgXXX.i file, look
; at the includes for examples... Stuff in these two
; files is considered private for your sublibrary...
; If it happens, that your board has a Video RAM organisation
; that currently is not supported by rtgsublibs.i,
; please inform me, so that i can
; modify the Include file...
_FreeScreenModes ; IN: a0.l = List of ScreenModes or zero
; IN: a6.l = rtgCGX.library base
;COM: you may destroy d0-d1,a0-a1
; Free the Screenmodelist again...
Insert the functions HERE :
_OpenRtgScreen:
_CloseRtgScreen:
_GetRtgScreenData:
_LockRtgScreen:
_UnlockRtgScreen:
_GetBufAdr:
_LoadRGBRtg:
_RtgScreenAtFront:
_SwitchScreens:
_WriteRtgPixel:
_WriteRtgPixelRGB:
_FillRtgRect:
_FillRtgRectRGB:
_WriteRtgPixelArray:
_WriteRtgPixelRGBArray:
_CopyRtgPixelArray:
_DrawRtgLine:
_DrawRtgLineRGB:
_WaitRtgSwitch:
_WaitRtgBlit:
_RtgWaitTOF:
_RtgBlit:
_RtgBltClear:
_CallRtgC2P:
_RtgText:
_RtgSetFont:
_RtgClearPointer:
_RtgSetPointer:
_RtgSetTextMode:
_RtgOpenFont:
_RtgCloseFont:
_RtgSetTextModeRGB:
_RtgInitRDCMP
_RtgWaitRDCMP
_RtgGetMsg
_RtgReplyMsg
_CopyRtgBlit
_RtgCheckVSync
; Some last notes :
; 1. For the blitting functions use the GFX Board Blitter
; 2. If the Board can't do the blitting functions without
; waiting on the Blitter, well, then do them WITH waiting
; and let WaitRtgBlit do simply nothing
; 3. CopyRtgPixelArray and CallRtgC2P have to be implemented
; in a way that they directly access the Video RAM. *NO*
; OS functions allowed !!!
; 4. For the Write...Pixel... functions OS functions are
; allowed... those color conversion stuff with the RGB ones
; is slow anyways...
; 5. The Draw and Fill Functions have to use the GFX Board
; blitter if this is possible
; 6. If the board does not need segmented memory, GetSegment
; and SetSegment simply do nothing (GetSegment returns 0
; in this case)
; 7. Your code should be 68020-optimized.
; 8. If some functions are NOT possible to be implemented on
; your board (like for example Pointer stuff for Picasso
; WB Emulation), simply let the functions do NOTHING. Do
; NOT simply leave them out, else applications that use
; them might crash. Also, send me a note about the fact,
; that certain functions can't be supported, and i will add
; something to the docs+autodocs
; 9. GetSegment/SetSegment were removed. They only remain
; in the code, so that the offsets do not change. But you
; can implement them as empty functions.
END